using System;
using System.Collections;
using System.IO;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Web;
public class TaobaoUtil
{
	public static int int_0 = 1;
	public static int int_1 = 3;
	public static Regex regex_0 = new Regex("^\\d+$");
	public static string string_0 = "<[^>]*>";
	public static bool smethod_0(string string_1)
	{
		Directory.GetCurrentDirectory();
		string address = "https://buyertrade.taobao.com/trade/itemlist/list_bought_items.htm";
		WebClient webClient = new WebClient();
		webClient.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
		webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36");
		webClient.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
		webClient.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8");
		webClient.Headers.Add("Cookie", string_1);
		byte[] array = webClient.DownloadData(address);
		string value = webClient.ResponseHeaders["Content-Encoding"];
		if ("gzip".Equals(value))
		{
			return GzipUtil.zip_to_string(array, Encoding.GetEncoding("GB2312")).Contains("<title>已买到的宝贝</title>");
		}
		Encoding.GetEncoding("GB2312").GetString(array);
		return false;
	}
	public static CouponItem get_coupon(string coupon_url)
	{
		if (!coupon_url.Contains("coupon") || !coupon_url.Contains("taobao.com"))
		{
			coupon_url = TaobaoUtil.get_redirect_url(coupon_url, coupon_url);
		}
		coupon_url = HttpUtility.UrlDecode(coupon_url);
		coupon_url = coupon_url.Replace("seller_id=", "sellerId=").Replace("activity_id=", "activityId=");
		string newValue = StringUtil.subString(coupon_url, 0, "sellerId=", "&");
		string newValue2 = StringUtil.subString(coupon_url, 0, "activityId=", "&");
		string text = "http://shop.m.taobao.com/shop/coupon.htm?seller_id={seller_id}&activity_id={activity_id}";
		string address = text.Replace("{seller_id}", newValue).Replace("{activity_id}", newValue2);
		WebClient webClient = new WebClient();
		webClient.Headers.Add("user-agent", "Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10");
		byte[] array = webClient.DownloadData(address);
		string text2 = "";
		string value = webClient.ResponseHeaders["Content-Encoding"];
		if ("gzip".Equals(value))
		{
			text2 = GzipUtil.zip_to_string(array, Encoding.UTF8);
		}
		else
		{
			text2 = Encoding.UTF8.GetString(array);
		}
		CouponItem couponItem = new CouponItem();
		if (!text2.Contains("该优惠券不存在或者已经过期"))
		{
			int num = text2.IndexOf("元优惠券");
			int num2 = 1;
			while (TaobaoUtil.regex_0.IsMatch(text2.Substring(num - num2, num2)))
			{
				num2++;
			}
			num2--;
			try
			{
				couponItem.int_0 = int.Parse(text2.Substring(num - num2, num2));
			}
			catch
			{
				couponItem.int_0 = 0;
			}
			try
			{
				couponItem.int_1 = int.Parse(StringUtil.subString(text2, 0, "<span class=\"rest\">", "</span>"));
			}
			catch
			{
				couponItem.int_1 = 0;
			}
			try
			{
				couponItem.int_2 = int.Parse(StringUtil.subString(text2, 0, "<span class=\"count\">", "</span>"));
			}
			catch
			{
				couponItem.int_2 = 0;
			}
			couponItem.string_0 = StringUtil.subString(text2, 0, "<dd>有效期:", "</dd>");
		}
		return couponItem;
	}
	public static ArrayList query_goods_comment(string string_1, string string_2, string string_3, string string_4, string string_5, int int_2, out string string_6)
	{
		string text = "";
		ArrayList result;
		try
		{
			WebClient webClient = new WebClient();
			webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17");
			webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
			webClient.Headers.Add("Cookie", string_4);
			string text2 = webClient.DownloadString("http://item.taobao.com:80/item.htm?id=" + string_1);
			bool flag = text2.IndexOf("天猫</title>") != -1;
			int num = text2.IndexOf("sellerId") + 10;
			int length = text2.IndexOf(flag ? "\"" : ",", num) - num;
			string newValue = text2.Substring(num, length).Replace(" ", "").Replace("'", "").Replace(":", "");
			string text3 = "https://rate.taobao.com/feedRateList.htm?auctionNumId={itemId}&userNumId={sellerId}&currentPageNum={currentPage}&pageSize=20&rateType=&orderType=feedbackdate&showContent=1&attribute=&sku=&hasSku=false&folded=0&_ksTS=1465821754822_2153&callback=jsonp_tbcrate_reviews_list";
			if (flag)
			{
				text3 = "https://rate.tmall.com/list_detail_rate.htm?sellerId={sellerId}&itemId={itemId}&order=3&currentPage={currentPage}&append=0&content=1&tagId=&posi=&picture=";
			}
			ArrayList arrayList = new ArrayList();
			int num2 = 1;
			while (true)
			{
				Thread.Sleep(int.Parse(string_5));
				webClient.Headers.Clear();
				webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17");
				webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
				webClient.Headers.Add("Referer", "https://detail.tmall.com/item.htm?id=" + string_1);
				webClient.Headers.Add("Cookie", string_4);
				string address = text3.Replace("{sellerId}", newValue).Replace("{itemId}", string_1).Replace("{currentPage}", string.Concat(num2));
				text = webClient.DownloadString(address);
				if (text.Contains(flag ? "\"rateList\":[]" : "\"comments\":[]"))
				{
					goto IL_217;
				}
				if (text.Contains("\"url\":\"https://sec.taobao.com"))
				{
					break;
				}
				TaobaoUtil.smethod_11(flag, arrayList, text, string_3);
				int num3 = int.Parse(StringUtil.subString(text, 0, flag ? "\"lastPage\":" : "\"maxPage\":", ","));
				if (num2 >= num3 || TaobaoUtil.smethod_13(arrayList, string_3) >= int.Parse(string_2) || num2 > int_2)
				{
					goto IL_217;
				}
				num2++;
			}
			string_6 = text;
			result = null;
			return result;
			IL_217:
			TaobaoUtil.smethod_19(arrayList);
			string_6 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_6 = "【" + text + "】，" + ex.ToString();
			result = null;
		}
		return result;
	}
	private static void smethod_11(bool bool_0, ArrayList arrayList_0, string string_1, string string_2)
	{
		string text = StringUtil.subString(string_1, 0, bool_0 ? "\"rateList\":[{\"" : "\"comments\":[{\"", "\"");
		text = "\"" + text + "\":";
		int num = 0;
		while ((num = string_1.IndexOf(text, num)) != -1)
		{
			int num2 = string_1.IndexOf(text, num + 1);
			if (num2 == -1)
			{
				num2 = string_1.Length;
			}
			string text2 = string_1.Substring(num, num2 - num);
			int num3 = 0;
			string text3;
			while (true)
			{
				num3 = text2.IndexOf("\"rateContent\":\"", num3);
				if (num3 != -1)
				{
					if (bool_0)
					{
						num3 += 15;
					}
					else
					{
						num3 += 11;
					}
					int num4 = text2.IndexOf("\",", num3);
					int num5 = text2.IndexOf("\"},", num3);
					int num6 = num4;
					if (num6 > num5 && num5 != -1)
					{
						num6 = num5;
					}
					text3 = TaobaoUtil.smethod_20(text2.Substring(num3, num6 - num3));
					if (!text3.Contains("评价方未及时做出评价") && !text3.Equals("好评！"))
					{
						if (text3.Length >= int.Parse(string_2))
						{
							break;
						}
						num3++;
					}
				}
			}
			string text4 = StringUtil.subString(text2, 0, bool_0 ? "\"id\":" : "\"rateId\":", ",");
			string string_3 = StringUtil.subString(text2, 0, bool_0 ? "\"displayUserNick\":\"" : "\"nick\":\"", "\"");
			string text5 = StringUtil.subString(text2, 0, bool_0 ? "\"rateDate\":\"" : "\"date\":\"", "\"");
			if (!bool_0)
			{
				text5 = text5.Replace("年", "-").Replace("月", "-").Replace("日", "") + ":00";
			}
			TaobaoUtil.smethod_12(arrayList_0, new GoodsComment
			{
				string_0 = text4,
				string_1 = text5,
				string_2 = string_3,
				string_3 = text3
			});
			num++;
		}
	}
	private static void smethod_12(ArrayList arrayList_0, GoodsComment gclass27_0)
	{
		bool flag = false;
		IEnumerator enumerator = arrayList_0.GetEnumerator();
		while (enumerator.MoveNext())
		{
			GoodsComment goodsComment = (GoodsComment)enumerator.Current;
			if (goodsComment.string_3.Equals(gclass27_0.string_3))
			{
				flag = true;
				//IL_36:
				if (!flag)
				{
					arrayList_0.Add(gclass27_0);
				}
				return;
			}
		}
		//goto IL_36;
	}
	private static int smethod_13(ArrayList arrayList_0, string string_1)
	{
		int num = 0;
		foreach (GoodsComment goodsComment in arrayList_0)
		{
			if (goodsComment.string_3.Length >= int.Parse(string_1))
			{
				num++;
			}
		}
		return num;
	}
	public static ArrayList smethod_14(string string_1, string string_2, string string_3, string string_4, string string_5)
	{
		return TaobaoUtil.smethod_15(string_1, string_2, string_3, string_4, string_5, 5);
	}
	public static ArrayList smethod_15(string string_1, string string_2, string string_3, string string_4, string string_5, int int_2)
	{
		WebClient webClient = new WebClient();
		webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17");
		webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
		webClient.Headers.Add("Cookie", string_4);
		string text = webClient.DownloadString("http://item.taobao.com:80/item.htm?id=" + string_1);
		bool flag = text.IndexOf("天猫</title>") != -1;
		int num = text.IndexOf("sellerId") + 10;
		int length = text.IndexOf(flag ? "\"" : ",", num) - num;
		string newValue = text.Substring(num, length).Replace(" ", "").Replace("'", "").Replace(":", "");
		string text2 = "https://rate.taobao.com/feedRateList.htm?auctionNumId={itemId}&userNumId={sellerId}&currentPageNum={currentPage}&pageSize=20&rateType=&orderType=feedbackdate&showContent=1&attribute=&sku=&hasSku=false&folded=0&_ksTS=1465821754822_2153&callback=jsonp_tbcrate_reviews_list";
		if (flag)
		{
			text2 = "https://rate.tmall.com/list_detail_rate.htm?sellerId={sellerId}&itemId={itemId}&order=3&currentPage={currentPage}&append=0&content=1&tagId=&posi=&picture=";
		}
		ArrayList arrayList = new ArrayList();
		int num2 = 1;
		while (true)
		{
			Thread.Sleep(int.Parse(string_5));
			webClient.Headers.Clear();
			webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17");
			webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
			webClient.Headers.Add("Referer", "https://detail.tmall.com/item.htm?id=" + string_1);
			webClient.Headers.Add("Cookie", string_4);
			string address = text2.Replace("{sellerId}", newValue).Replace("{itemId}", string_1).Replace("{currentPage}", string.Concat(num2));
			string text3 = webClient.DownloadString(address);
			if (text3.Contains(flag ? "\"rateList\":[]" : "\"comments\":[]"))
			{
				break;
			}
			TaobaoUtil.smethod_17(flag, arrayList, text3, string_3);
			int num3 = int.Parse(StringUtil.subString(text3, 0, flag ? "\"lastPage\":" : "\"maxPage\":", ","));
			if (num2 >= num3 || TaobaoUtil.smethod_16(arrayList, string_3) >= int.Parse(string_2) || num2 > int_2)
			{
				break;
			}
			num2++;
		}
		TaobaoUtil.smethod_19(arrayList);
		return arrayList;
	}
	private static int smethod_16(ArrayList arrayList_0, string string_1)
	{
		int num = 0;
		foreach (string text in arrayList_0)
		{
			if (text.Length >= int.Parse(string_1))
			{
				num++;
			}
		}
		return num;
	}
	private static void smethod_17(bool bool_0, ArrayList arrayList_0, string string_1, string string_2)
	{
		string value = bool_0 ? "\"rateContent\":\"" : "\"content\":\"";
		int num = 0;
		while ((num = string_1.IndexOf(value, num)) != -1)
		{
			int num2 = num + 11;
			if (bool_0)
			{
				num2 += 15;
			}
			int num3 = string_1.IndexOf("\",", num2);
			int num4 = string_1.IndexOf("\"},", num2);
			int num5 = num3;
			if (num5 > num4 && num4 > 0)
			{
				num5 = num4;
			}
			string text = TaobaoUtil.smethod_20(string_1.Substring(num2, num5 - num2));
			if (!text.Contains("评价方未及时做出评价") && !text.Equals("好评！") && text.Length >= int.Parse(string_2))
			{
				TaobaoUtil.smethod_18(arrayList_0, text);
			}
			num = num5;
		}
	}
	private static void smethod_18(ArrayList arrayList_0, string string_1)
	{
		bool flag = false;
		IEnumerator enumerator = arrayList_0.GetEnumerator();
		while (enumerator.MoveNext())
		{
			string text = (string)enumerator.Current;
			if (text.Equals(string_1))
			{
				flag = true;
				//IL_2C:
				if (!flag)
				{
					arrayList_0.Add(string_1);
				}
				return;
			}
		}
		//goto IL_2C;
	}
	private static void smethod_19(ArrayList arrayList_0)
	{
		for (int i = 0; i < arrayList_0.Count - 1; i++)
		{
			for (int j = i; j < arrayList_0.Count; j++)
			{
				if (arrayList_0[i].ToString().Length < arrayList_0[j].ToString().Length)
				{
					string value = (string)arrayList_0[i];
					arrayList_0[i] = arrayList_0[j];
					arrayList_0[j] = value;
				}
			}
		}
	}
	public static ArrayList smethod_2(string string_1)
	{
		string text = "https://qing.taobao.com/json/tg/ajaxGetItemsV2.json?type=0&salesSite=3&platformIds=34033%2C34032&timeFilter=now&stype=rank0&psize=100&page={pageno}&callback=jsonp48";
		WebClient webClient = new WebClient();
		webClient.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
		webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36");
		webClient.Headers.Add("Accept-Encoding", "gzip,deflate,sdch");
		webClient.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8,en-US;q=0.5,en;q=0.3");
		webClient.Headers.Add("X-Requested-With", "XMLHttpRequest");
		webClient.Headers.Add("Referer", "https://qing.taobao.com");
		webClient.Headers.Add("Cookie", string_1);
		ArrayList arrayList = new ArrayList();
		int num = 1;
		while (true)
		{
			string address = text.Replace("{pageno}", string.Concat(num));
			string text2 = GzipUtil.zip_to_string(webClient.DownloadData(address), Encoding.UTF8);
			int num2 = 0;
			while ((num2 = text2.IndexOf("\"baseinfo\"", num2)) != -1)
			{
				arrayList.Add(new GoodsItem1
				{
					num_iid = StringUtil.subString(text2, num2, "\"itemId\":", ","),
					title = StringUtil.subString(text2, num2, "\"title\":\"", "\""),
					user_num_id = StringUtil.subString(text2, num2, "\"sellerId\":", ","),
					price = StringUtil.subString(text2, num2, "\"actPrice\":\"", "\"")
				});
				num2++;
			}
			string s = StringUtil.subString(text2, 0, "\"totalPage\":", ",");
			if (num >= int.Parse(s))
			{
				break;
			}
			num++;
		}
		return arrayList;
	}
	public static string smethod_20(string string_1)
	{
		return Regex.Replace(string_1, TaobaoUtil.string_0, "").Replace("\\", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("?", "").Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "").Replace("\n", "").Replace("\r", "").Replace("u0001", "").Replace("&hellip;", "...");
	}
	public static string get_redirect_url(string url, string referer_url)
	{
		HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
		if (url.Contains("coupon") && url.Contains("taobao.com"))
		{
			httpWebRequest.UserAgent = "Mozilla/5.0 (iPad; U; CPU OS 3_2_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B500 Safari/531.21.10";
		}
		else
		{
			httpWebRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17";
		}
		httpWebRequest.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*";
		httpWebRequest.Referer = referer_url;
		httpWebRequest.Headers.Add("Accept-Language", "zh-cn");
		string value = CookieUtil.get_cookie("http://www.taobao.com");
		httpWebRequest.Headers.Add("Cookie", value);
		httpWebRequest.AllowAutoRedirect = false;
		httpWebRequest.Method = "GET";
		httpWebRequest.Timeout = 2000;
		HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
		StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
		string text = streamReader.ReadToEnd();
		httpWebResponse.Close();
		streamReader.Close();
		if (HttpStatusCode.Found.Equals(httpWebResponse.StatusCode) || HttpStatusCode.MovedPermanently.Equals(httpWebResponse.StatusCode))
		{
			string text2 = httpWebResponse.Headers.Get("Location").ToString();
			if (text2.Contains("/t_js?tu="))
			{
				return TaobaoUtil.get_redirect_url(TaobaoUtil.smethod_22(text2.Split(new char[]
				{
					'='
				})[1]), text2);
			}
			if (text2.Contains("coupon") && text2.Contains("taobao.com"))
			{
				return text2;
			}
			if (text2.Contains("item.htm?id="))
			{
				return text2;
			}
			if (text2.Contains("detail.ju.taobao.com"))
			{
				return text2;
			}
			if ((text2.Contains("taobao.com") || text2.Contains("tmall.com") || text2.Contains("yao.95095.com")) && text2.Contains("item.htm") && text2.Contains("id="))
			{
				return text2;
			}
			if (text2.Contains("shop/view_shop.htm?user_number_id="))
			{
				return text2;
			}
			return TaobaoUtil.get_redirect_url(text2, text2);
		}
		else
		{
			if (url.Contains("m.tb.cn"))
			{
				int num = text.IndexOf("var url = '") + 11;
				int length = text.IndexOf("'", num) - num;
				return TaobaoUtil.get_redirect_url(text.Substring(num, length), url);
			}
			return url;
		}
	}
	public static string smethod_22(string string_1)
	{
		if (string_1 == null)
		{
			return string.Empty;
		}
		StringBuilder stringBuilder = new StringBuilder();
		int length = string_1.Length;
		int num = 0;
		while (num != length)
		{
			if (Uri.IsHexEncoding(string_1, num))
			{
				stringBuilder.Append(Uri.HexUnescape(string_1, ref num));
			}
			else
			{
				stringBuilder.Append(string_1[num++]);
			}
		}
		return stringBuilder.ToString();
	}
	public static BrandItem smethod_3(string string_1, string string_2)
	{
		BrandItem brandItem = new BrandItem();
		string address = "http://item.taobao.com/item.htm?spm=0.0.0.0.7NgNnN&id=" + string_1;
		string text = GzipUtil.zip_to_string(new WebClient
		{
			Headers = 
			{

				{
					"Accept",
					"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
				},

				{
					"User-Agent",
					"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
				},

				{
					"Referer",
					"http://pub.alimama.com/myunion.htm?spm=a219t.7473494.1998155389.3.5o4qvy"
				},

				{
					"Accept-Encoding",
					"gzip,deflate,sdch"
				},

				{
					"Accept-Language",
					"zh-CN,zh;q=0.8"
				},

				{
					"Cookie",
					string_2
				}
			}
		}.DownloadData(address), Encoding.GetEncoding("GB2312"));
		int num = text.IndexOf("<ul id=\"J_AttrUL\">");
		if (num != -1)
		{
			int num2 = text.IndexOf("品牌:", num);
			if (num2 != -1)
			{
				num2 += 3;
				int num3 = text.IndexOf("<", num2) - num2;
				if (num3 > 0)
				{
					string text2 = TaobaoUtil.smethod_4(GzipUtil.smethod_4(text.Substring(num2, num3)));
					brandItem.string_0 = text2;
				}
			}
			int num4 = text.IndexOf("型号:", num);
			if (num4 != -1)
			{
				num4 += 3;
				int num5 = text.IndexOf("<", num4) - num4;
				if (num5 > 0)
				{
					string string_3 = TaobaoUtil.smethod_4(GzipUtil.smethod_4(text.Substring(num4, num5)));
					brandItem.string_1 = string_3;
				}
			}
			int num6 = text.IndexOf("货号:", num);
			if (num6 != -1)
			{
				num6 += 3;
				int num7 = text.IndexOf("<", num6) - num6;
				if (num7 > 0)
				{
					string string_4 = TaobaoUtil.smethod_4(GzipUtil.smethod_4(text.Substring(num6, num7)));
					brandItem.string_2 = string_4;
				}
			}
			int num8 = text.IndexOf("</ul>", num) - num;
			if (num8 > 0)
			{
				string text3 = TaobaoUtil.smethod_4(GzipUtil.smethod_4(text.Substring(num, num8)));
				text3 = text3.Substring(0, text3.LastIndexOf("</li>") + 5) + "</ul>";
				brandItem.string_3 = text3;
			}
		}
		return brandItem;
	}
	public static string smethod_4(string string_1)
	{
		return string_1.Replace("&rsquo;", "’").Replace("&amp;", "&").Replace("&middot;", "·").Replace("&mdash;", "—").Replace("\r", "").Replace("\n", "").Replace("\t", "");
	}
	public static StoreItem1 smethod_5(string string_1, string string_2)
	{
		StoreItem1 storeItem = new StoreItem1();
		string address = "http://store.taobao.com/shop/view_shop.htm?user_number_id=" + string_1;
		string text = new WebClient
		{
			Headers = 
			{

				{
					"Accept",
					"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8"
				},

				{
					"User-Agent",
					"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
				},

				{
					"Referer",
					"http://pub.alimama.com/myunion.htm?spm=a219t.7473494.1998155389.3.5o4qvy"
				},

				{
					"Cookie",
					string_2
				}
			}
		}.DownloadString(address);
		if (text.IndexOf("slogo-shopname") != -1)
		{
			int num = text.IndexOf(">", text.IndexOf("slogo-shopname"));
			int length = text.IndexOf("</a>", num) - num;
			string text2 = TaobaoUtil.smethod_20(text.Substring(num, length)).Replace(" ", "");
			storeItem.string_0 = text2;
			string string_3 = StringUtil.subString(text, text.IndexOf("slogo-shopname"), "href=\"http://", ".tmall.");
			storeItem.string_3 = string_3;
		}
		try
		{
			if (text.IndexOf("公 司 名") != -1)
			{
				int num2 = text.IndexOf("<div class=\"right\">", text.IndexOf("公 司 名"));
				int length2 = text.IndexOf("</div>", num2) - num2;
				string string_4 = TaobaoUtil.smethod_20(text.Substring(num2, length2)).Replace(" ", "");
				storeItem.string_1 = string_4;
			}
			if (text.IndexOf("服务电话") != -1)
			{
				int num3 = text.IndexOf("<div class=\"right\">", text.IndexOf("服务电话"));
				int length3 = text.IndexOf("</div>", num3) - num3;
				string string_5 = TaobaoUtil.smethod_20(text.Substring(num3, length3)).Replace(" ", "");
				storeItem.string_2 = string_5;
			}
		}
		catch (Exception)
		{
		}
		return storeItem;
	}
	public static ShopItem smethod_6(string string_1, string string_2)
	{
		ShopItem result;
		try
		{
			string text = "http://s.taobao.com/search?q=+{shopname}+&commend=all&ssid=s5-e&search_type=shop&sourceId=tb.index&spm=1.7274553.1997520841.1&initiative_id=tbindexz_20150108&app=shopsearch&q=+{shopname}+&commend=all&ssid=s5-e&search_type=shop&sourceId=tb.index&spm=1.7274553.1997520841.1&initiative_id=tbindexz_20150108";
			text = text.Replace("{shopname}", HttpUtility.UrlEncode(string_1));
			string text2 = new WebClient
			{
				Headers = 
				{

					{
						"User-Agent",
						"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36"
					},

					{
						"Cookie",
						string_2
					}
				}
			}.DownloadString(text);
			string text3 = ">";
			int num = text2.IndexOf(text3, text2.IndexOf(">", text2.IndexOf("shop-info-list")) + 1) + text3.Length;
			int length = text2.IndexOf("<", num) - num;
			string text4 = text2.Substring(num, length).Trim();
			text3 = "class=\"J_WangWang\" data-encode=\"true\" data-nick=\"";
			int num2 = text2.IndexOf(text3) + text3.Length;
			int length2 = text2.IndexOf("\"", num2) - num2;
			string string_3 = HttpUtility.UrlDecode(text2.Substring(num2, length2).Trim());
			text3 = "class=\"shop-address\">";
			int num3 = text2.IndexOf(text3) + text3.Length;
			int length3 = text2.IndexOf("<", num3) - num3;
			string string_4 = text2.Substring(num3, length3).Trim();
			text3 = "target=\"_blank\">";
			int num4 = text2.IndexOf(text3, text2.IndexOf("主营:")) + text3.Length;
			int length4 = text2.IndexOf("</a>", num4) - num4;
			string string_5 = GzipUtil.html_to_text(text2.Substring(num4, length4).Trim());
			text3 = "<img src=\"";
			int num5 = text2.IndexOf(text3, text2.IndexOf("list-img")) + text3.Length;
			int length5 = text2.IndexOf("\"", num5) - num5;
			string string_6 = GzipUtil.html_to_text(text2.Substring(num5, length5).Trim());
			result = new ShopItem
			{
				string_0 = text4,
				string_1 = string_3,
				string_2 = string_4,
				string_3 = string_5,
				string_4 = string_6
			};
		}
		catch (Exception)
		{
			result = null;
		}
		return result;
	}
	public static ArrayList smethod_7(string string_1, string string_2, int int_2, out string string_3)
	{
		ArrayList arrayList = new ArrayList();
		int i = 1;
		while (i <= int_2)
		{
			ArrayList arrayList2 = TaobaoUtil.smethod_8(string_1, string_2, i, out string_3);
			if (arrayList2 == null)
			{
				return null;
			}
			if (arrayList2.Count == 0)
			{
				return arrayList;
			}
			arrayList.AddRange(arrayList2);
			if (arrayList2.Count != 44)
			{
				return arrayList;
			}
			i++;
			Thread.Sleep(5000);
		}
		string_3 = "";
		return arrayList;
	}
	public static ArrayList smethod_8(string string_1, string string_2, int int_2, out string string_3)
	{
		string text = "";
		ArrayList result;
		try
		{
			string text2 = "https://s.taobao.com/search?q={schkey}&js=1&ie=utf8&sort=sale-desc";
			if (int_2 > 1)
			{
				text2 = "https://s.taobao.com/search?q={schkey}&js=1&ie=utf8&sort=sale-desc&bcoffset=0&p4ppushleft=%2C44&s={pageno}";
				text2 = text2.Replace("{pageno}", string.Concat((int_2 - 1) * 44));
			}
			text2 = text2.Replace("{schkey}", HttpUtility.UrlEncode(string_1));
			WebClient webClient = new WebClient();
			webClient.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36");
			webClient.Headers.Add("Upgrade-Insecure-Requests", "1");
			webClient.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
			webClient.Headers.Add("Accept-Encoding", "gzip, deflate, sdch");
			webClient.Headers.Add("Accept-Language", "zh-CN,zh;q=0.8");
			webClient.Headers.Add("Cookie", string_2);
			byte[] array = webClient.DownloadData(text2);
			string value = webClient.ResponseHeaders["Content-Encoding"];
			if ("gzip".Equals(value))
			{
				text = GzipUtil.zip_to_string(array, Encoding.UTF8);
			}
			else
			{
				text = Encoding.UTF8.GetString(array);
			}
			ArrayList arrayList = new ArrayList();
			string text3 = StringUtil.subString(text, 0, "\"auctions\":[{\"", "\"");
			text3 = "\"" + text3 + "\":";
			int num = 0;
			while ((num = text.IndexOf(text3, num)) != -1)
			{
				arrayList.Add(new GoodsItem
				{
					num_iid = StringUtil.subString(text, num, "\"nid\":\"", "\""),
					title = StringUtil.subString(text, num, "\"raw_title\":\"", "\",").Replace("'", "")
				});
				num++;
			}
			string_3 = "";
			result = arrayList;
		}
		catch (Exception ex)
		{
			string_3 = "【" + text + "】，" + ex.ToString();
			result = null;
		}
		return result;
	}
	public static ArrayList smethod_9(string string_1, string string_2, string string_3, string string_4, string string_5)
	{
		return TaobaoUtil.smethod_9(string_1, string_2, string_3, string_4, string_5);
	}
}
